/*****************************************************************************
 *
 * Copyright (c), 2004-2020,ShangHai Neotune Information Technology Co., Ltd.
 *
 * Module Name : asn1conf.h
 *
 * Author :    sean
 *
 * Date :    2004-02-05
 *
 * Version :    1.00
 *
 * Description :    
 *
 * Other :    
 *
 * Data Structure List: <Main Data Structure>
 *
 * Modification History
 * ---------------------------------------------------------------------------
 *  1: Data :      2004-02-05
 *    Author :     sean
 *    Version :    V100R001M00
 *    Modification : creation
 *
*****************************************************************************/

#if !defined(asn1conf_inc)
#define asn1conf_inc

#ifdef __cplusplus
extern"C" {
#endif

#if !defined(EPILOGUE_INSTALL_H)
#include "install.h"
#endif

/* Get the standard types and the install defines */
#if !defined(EPILOGUE_TYPES_H)
#include "snmptypes.h"
#endif

/* !!! These are here for backwards compatibility only while we're switching
 * over to the new configuration system. */
#if (INSTALL_ENVOY_SNMP_GROUP_V1 || INSTALL_ENVOY_SNMP_GROUP_V2)
#define SGRP 1
#endif

/* This is to provide compatibility for neosnet users because the
 * neosnet version of envoy had all struct declarations bracketted 
 * with an alignment pragma based on this test.  We will follow
 * suit but put the test in a single place (here). */
#if INSTALL_ENVOY_ALIGN_STRUCTURES
#define NEOSNET_STRUCT_ALIGN
#endif

/*****************************************************************
 * Portable types definitions for backwards compatibility.  These
 * are now defined in terms of things defined by <types.h> and
 * therefore <oemtypes.h> so any changes should be made in
 * <oemtypes.h>.
 *****************************************************************/
        /* various sizes of integers */
typedef sbits32_t       INT_32_T;
typedef bits32_t        UINT_32_T;
typedef sbits16_t       INT_16_T;
typedef bits16_t        UINT_16_T;
typedef bits8_t         UINT_8_T;
typedef bits8_t         OCTET_T ;
        /* A generic pointer type.  Use void * if your compiler can hack
         * it, otherwise char * is probably the right thing. */
typedef ptr_t           PTR_T;
        /* SNMP ASN.1 tags and lengths can always fit into 16 bits...   */
typedef bits16_t        ATVALUE_T;      /* ASN.1 type values            */
typedef bits16_t        ALENGTH_T;      /* ASN.1 contents field lengths */
        /* this is used as both a maximum and a mask */
#define MAX_ALENGTH     0xFFFF

#define OCTETS_PER_INT32    (sizeof(INT_32_T)/sizeof(OCTET_T))
#define OCTETS_PER_INT16    (sizeof(INT_16_T)/sizeof(OCTET_T))


/*
 * get the common system configuration
 */
#include "snmpconfig.h"

/*
 * get the system configuration for envoy
 */
#define CONFIG_PREAMBLE 1
#include "envoy.h"
#undef CONFIG_PREAMBLE


/* Long lived dynamic storage.  If the user doesn't define
   them explicitly we use the shorter term ones */
#ifndef SNMP_memory_alloc_lt
#define SNMP_memory_alloc_lt(need) SNMP_memory_alloc(need)
#endif

#ifndef SNMP_memory_free_lt
#define SNMP_memory_free_lt(buf) SNMP_memory_free(buf)
#endif

/*****************************************************************
 * Set the size of object identifier components.  32 bits is recommended
 * but 16 bits may work and may save a little space.
 * This may be overridden in <oemtypes.h> by defining __TYPES_HAVE_OIDC_T_
 *****************************************************************/
#ifndef __TYPES_HAVE_OIDC_T_
typedef bits32_t        OIDC_T;
#endif

/* min and max macros if not provided by the system */
#if (!defined(max))
#define max(a,b)    (((a) > (b)) ? (a) : (b))
#endif
#if (!defined(min))
#define min(a,b)    (((a) < (b)) ? (a) : (b))
#endif

/* These are the standard C functions that we use in Envoy.  If the
 * customer's compiler supplies these correctly then nothing more need be
 * done.  If not, then <envoy.h> can override.  The most common case is
 * that the system provides them but with the wrong type arguments (char *
 * instead of void *).  The macros can then fix this with casts. */
#ifndef MEMCPY
#define MEMCPY(dst, src, n) memcpy(dst, src, n)
#endif
#ifndef MEMSET
#define MEMSET(dst, val, n) memset(dst, val, n)
#endif
#ifndef MEMCMP
#define MEMCMP(s1, s2, n) memcmp(s1, s2, n)
#endif
#ifndef STRLEN
#define STRLEN(s) strlen(s)
#endif

#ifndef MEMCMP_NULLOK
#define MEMCMP_NULLOK(s1, s2, n) (n ? MEMCMP(s1, s2, n) : 0)
#endif

/* SNMP_ERROR checking, Look for inconsistencies or necessary configuration
   that hasn't been done */

/* Do we need any of the stats.  For v1 & v2 there is a seperate
   installation option for the stats groups, for v3 the stats
   are required for reports so installing v3 installs the groups */
#if (INSTALL_ENVOY_SNMP_GROUP_V1 || INSTALL_ENVOY_SNMP_GROUP_V2 || \
     INSTALL_ENVOY_SNMP_VERSION_3)
#define ENVOY_NEED_STATS 1
#else
#define ENVOY_NEED_STATS 0
#endif

/* See if we need either v2 types or protocols, we do this
   to avoid needing to add new install option whenever a new
   version is defined */
#if (INSTALL_ENVOY_SNMP_USE_V2_TYPES || INSTALL_ENVOY_SNMP_VERSION_2 || \
     INSTALL_ENVOY_SNMP_VERSION_3)
#define ENVOY_USE_V2_TYPES 1
#else
#define ENVOY_USE_V2_TYPES 0
#endif

#if (INSTALL_ENVOY_SNMP_VERSION_2 || INSTALL_ENVOY_SNMP_VERSION_3)
#define ENVOY_USE_V2_PROTOS 1
#else
#define ENVOY_USE_V2_PROTOS 0
#endif

/* If version 3 is installed we must have 2275 views */
#if ((INSTALL_ENVOY_SNMP_VERSION_3) && !(INSTALL_ENVOY_SNMP_RFC2275_VIEWS))
#SNMP_ERROR If you are installing version 3 you must also install rfc2275
#SNMP_ERROR views using _ENVOY_SNMP_RFC2275_VIEWS.
#endif

/* check that only one of the view schemes is turned on, 
   if one is turned on turn on the flex view option for use
   elsewhere */
#if (INSTALL_ENVOY_SNMP_RFC1445_VIEWS && INSTALL_ENVOY_SNMP_RFC2275_VIEWS)
#SNMP_ERROR Must not have both the rfc1445 and rfc2275 view schemes installed.
#SNMP_ERROR You should modify the configuration file and remove either the
#SNMP_ERROR ENVOY_SNMP_RFC1445_VIEWS or ENVOY_SNMP_RFC2275_VIEWS option
#endif

#if (INSTALL_ENVOY_SNMP_RFC1445_VIEWS || INSTALL_ENVOY_SNMP_RFC2275_VIEWS)
#define INSTALL_ENVOY_SNMP_DYNAMIC_VIEWS 1
#else
#define INSTALL_ENVOY_SNMP_DYNAMIC_VIEWS 0
#endif

/* Check that that the lock & serialization options are consistent */
#if (INSTALL_ENVOY_SNMP_LOCK && INSTALL_ENVOY_SNMP_SERIALIZE)
#SNMP_ERROR Must not have both the lock code and the serialization code installed.
#SNMP_ERROR You should modify the configuration file and remove either
#SNMP_ERROR the ENVOY_SNMP_LOCK or the ENVOY_SNMP_SERIALIZE option
#endif

#if (INSTALL_ENVOY_CONTINUE_REENTRANT && !INSTALL_ENVOY_SNMP_LOCK)
#SNMP_ERROR Must have locks installed to use reentrant continues.
#SNMP_ERROR You should modify the configuration file and install
#SNMP_ERROR the ENVOY_SNMP_LOCK option.
#endif

/* check that the options for our sub agent scheme are consistent */
#if ((INSTALL_ENVOY_EPI_MASTER || INSTALL_ENVOY_EPI_SUB) && \
     !(INSTALL_ENVOY_EPI_SUBAGENT_SCHEME))
#SNMP_ERROR You must install ENVOY_EPI_SUBAGENT_SCHEME with ENVOY_EPI_MASTER
#SNMP_ERROR and ENVOY_EPI_SUB
#endif

#if (INSTALL_ENVOY_EPI_MASTER)
#if !(INSTALL_ENVOY_MAIN_AGENT)
#SNMP_ERROR You must install ENVOY_MAIN_AGENT for use with a master agent
#endif

#if !(INSTALL_ENVOY_SNMP_DYNAMIC_VIEWS)
#SNMP_ERROR You must install ENVOY_SNMP_RFC1445_VIEWS or
#SNMP_ERROR ENVOY_SNMP_RFC2275_VIEWS for use with a master agent
#endif

#if (!INSTALL_ENVOY_SNMP_LOCK && !INSTALL_ENVOY_SNMP_SERIALIZE)
#SNMP_ERROR Must have either the locking scheme or the serialization scheme
#SNMP_ERROR installed.  You should modify the configuration file and install
#SNMP_ERROR either the ENVOY_SNMP_LOCK or ENVOY_SNMP_SERIALIZE option
#endif
#endif

/* check that the options for the agentx scheme are consistent */
#if ((INSTALL_ENVOY_AGENTX_MASTER || INSTALL_ENVOY_AGENTX_SUB) && \
     !(INSTALL_ENVOY_AGENTX))
#SNMP_ERROR You must install ENVOY_AGENTX with ENVOY_AGENTX_MASTER
#SNMP_ERROR and ENVOY_AGENTX_SUB
#endif


#if (INSTALL_ENVOY_AGENTX_MASTER)
#if (INSTALL_ENVOY_MAIN_AGENT && !(INSTALL_ENVOY_SNMP_DYNAMIC_VIEWS))
#SNMP_ERROR You must install ENVOY_SNMP_RFC1445_VIEWS or
#SNMP_ERROR ENVOY_SNMP_RFC2275_VIEWS for use with a master agent
#endif

#if (!INSTALL_ENVOY_SNMP_LOCK && !INSTALL_ENVOY_SNMP_SERIALIZE)
#SNMP_ERROR Must have either the locking scheme or the serialization scheme
#SNMP_ERROR installed.  You should modify the configuration file and install
#SNMP_ERROR either the ENVOY_SNMP_LOCK or ENVOY_SNMP_SERIALIZE option
#endif
#endif

/* Check that the various SNMPv3 components are consistent */
#if ((INSTALL_ENVOY_SNMP_V3_NOTIFY) && !(INSTALL_ENVOY_SNMP_V3_TARGET))
#SNMP_ERROR The use of notifies requires that ENVOY_SNMP_V3_TARGET be installed.
#endif

/* If we don't have a main agent we shouldn't be counting stats */
#if ((INSTALL_ENVOY_SNMP_GROUP_V1 || INSTALL_ENVOY_SNMP_GROUP_V2) && \
     !(INSTALL_ENVOY_MAIN_AGENT))
#SNMP_ERROR Must not have the stats groups installed if building only a 
#SNMP_ERROR sub agent.  You should modify the configuration file
#SNMP_ERROR for the makmak program and either uninstall the SNMP_GROUP
#SNMP_ERROR options, add the MASTER agent option or remove the SUB agent option
#endif

#if INSTALL_ENVOY_SNMP_VERSION_USEC
#SNMP_ERROR Envoy no longer supports USEC.  Please uninstall 
#SNMP_ERROR ENVOY_SNMP_VERSION_USEC and recompile.
#endif

#if INSTALL_ENVOY_40_VB_FREE_COMPAT
#SNMP_ERROR ENVOY_40_VB_FREE_COMPAT is no longer a valid option.
#SNMP_ERROR Please uninstall it and recompile.
#endif

#ifdef __cplusplus
}
#endif

#endif /* asn1conf_inc */
